package org.bookie.model.hibernate;

import org.bookie.model.Account;
import org.bookie.model.Comment;
import org.bookie.model.User;
import org.hibernate.event.PostInsertEvent;
import org.hibernate.event.PostInsertEventListener;

public class UserPostInsertEventListener implements PostInsertEventListener {
	private static final long serialVersionUID = 1L;
	public void onPostInsert(PostInsertEvent event) {
		Object entity = event.getEntity();
		if(!entity.getClass().equals(User.class)){
			return;
		}
		User user = (User)entity;
		user.getAccount().deposit(Account.REFILL_AMOUNT, Comment.INITIAL);
	}

}
